using System.Collections.Generic;
using System.Linq;
using System.Net;

namespace LDNS.SDK.Commands.Models
{
    /// <summary>
    /// 设置主域名上游服务器命令类
    /// 作者: huobing
    /// </summary>
    public sealed class SetUpstreamMainDomainCommand : BaseCommand<DefaultCommandResult>
    {
        /// <summary>
        /// 命令名称
        /// </summary>
        public const string NAME = "SET_UPSTREAM_MAIN_DOMAIN";
        
        /// <summary>
        /// 获取命令名称
        /// </summary>
        public override string Name => NAME;
        
        /// <summary>
        /// 获取命令格式
        /// </summary>
        public override string Format => "SET_UPSTREAM_MAIN_DOMAIN <domain> <upstream>";
        
        /// <summary>
        /// 获取命令描述
        /// </summary>
        public override string Description => "设置特定主域名的上游服务器";
        
        /// <summary>
        /// 获取命令权限级别
        /// </summary>
        public override CommandPermission Permission => CommandPermission.Admin;
        
        /// <summary>
        /// 验证命令参数
        /// </summary>
        /// <param name="args">命令参数数组</param>
        /// <param name="error">错误信息输出</param>
        /// <returns>验证是否通过</returns>
        public override bool Validate(string[] args, out string error) 
        {
            error = string.Empty;
            if (args.Length != 2)
            {
                error = $"命令格式错误，使用: {Format}";
                return false;
            }
            return true;
        }
    }
}